# Maintainer: Alexander F. Rødseth <xyproto@archlinux.org>
# Contributor: Andrew Rabert <ar@nullsum.net>

pkgname=scrcpy
pkgver=2.2
pkgrel=1
pkgdesc='Display and control your Android device'
arch=(loong64 x86_64)
url='https://github.com/Genymobile/scrcpy'
license=(Apache)
depends=(android-tools ffmpeg sdl2)
makedepends=(meson)
source=("$pkgname-$pkgver.tar.gz::$url/archive/v$pkgver.tar.gz"
        "$url/releases/download/v$pkgver/$pkgname-server-v$pkgver")
b2sums=('6f11dbde6900ef818dbd3e5f1edb169d8acc2a4940675a2cadaec362c1a56c409fe8bcdeab7fcd208c5b4c038d2ddb5da5b0092d5743b27f3719d0970d5553e5'
        '65f53a9b931ab076f06de174c1212077d5961a28881237967894ca5f9f59006b4974c4fd6c1e878df9fa7804b848a92b03689f07e27fa32489e66dede5220363')

build() {
  mkdir -p build
  arch-meson build $pkgname-$pkgver \
    -D b_lto=true \
    -D b_ndebug=true \
    -D prebuilt_server=../$pkgname-server-v$pkgver \
    --buildtype release
  ninja -C build
}

package() {
  DESTDIR="$pkgdir" ninja -C build install
  install -Dm644 $pkgname-$pkgver/LICENSE -t "$pkgdir/usr/share/licenses/$pkgname"
}
